
$(function(){
	
	var hrefobj=GetRequest();
	if(hrefobj.source){
		window.location.href="web.html?sku_code="+hrefobj.sku_code;
	}else{
		//校验是否登陆
		checkoutlogin();
	}
	//打开关闭从底部向上打开的页面
	 $(document).on("open", ".weui-popup-modal", function() {
        //console.log("open popup");
      }).on("close", ".weui-popup-modal", function() {
        //console.log("close popup");
      });
    
	//得到年月
	getYear(1980,2022,function(data){
		$("#layoutdate").picker({  
     	 container: '#time-container',
     	 toolbar:false,
     	 inputReadOnly:true,
     	 cssClass:'datetimestyle',     	 
		  cols: [
		    {
		      textAlign: 'center',
		      values:data,
		      //如果你希望显示文案和实际值不同，可以在这里加一个displayValues: [.....]
		    },
		    {
		      textAlign: 'center',
		      values: ['1月', '2月', '3月', '4月', '5月', '6月', '7月','8月','9月','10月','11月','12月']
		    }
		  ],
		  onChange: function (picker, values, displayValues) {
          	//lym 2017 11.17 新增月历修改
          	dataObj.year=values[0].split('年')[0];
          	dataObj.month=values[1].split('月')[0]<10?'0'+values[1].split('月')[0]:values[1].split('月')[0];
        	}
		});
		
		//lym 2017 11.17 新增月历修改
		//var curentdate=new Date; 		
		//$("#layoutdate").picker("setValue", [curentdate.getFullYear()+"年", (curentdate.getMonth()+1)+"月"]);
		$("#layoutdate").picker("setValue", ["2018年", "1月"]);
		$(".selectdate").attr("style","display:none;");
	})
	
	//添加作品
	$(document).on("click",".crearworker",function(){
		//新建作品
	 	creatework()
		
	})
	
	
	
	
	//打开已经生成的作品
	$('.worker_con').on("click",".albumimg",function(event){
		$(".albumitem").removeClass("onfoucs");
		$(this).closest(".albumitem").addClass("onfoucs")
		if($(".albumitem").hasClass("onfoucs")){
		work_id=$(".onfoucs").attr("work_id");
		product_id=$(".onfoucs").attr("product_id");
		$("#loadtoast").show();	
		opentype=1;	
		var itemwork=UtilProperty[work_id];		
			if(itemwork.lay_list){
				//遍历布局列表
				lay_list();
			}else{
				//获取布局列表		
				lay_listajax();
			}	
			if(itemwork.worker){
				placeImageObj(work_id);				
			}else{		
				 //作品页面初始化接口 并且生成作品 得到页面数据
				initializationwork(work_id,function(layout_categoryid){
						opentype=1;		
						$(".workpage").show();				
						$("#originaleditor").show();						
						$("#loadtoast").hide();			
						$(".worker_con").hide();
						placeImageObj(work_id);
				});
				
			}
		}
	})
	
	
	$('#loadtoast').on("click",".weui-mask_transparent",function(event){
		event.stopPropagation();
 		
		
	})	
	//删除作品
	$('.worker_footer').on("click",".work_del",function(){		
		if(!$(this).hasClass("disablebtn")){
		var removearr=new Array();
		var isdel=false;
		$(".workeritem").find('input.work_input').each(function(i,e){
			var elem=$(e).closest('.albumitem');
			if($(e).is(':checked')&&elem.attr('status')==0){				
				removearr.push(elem.attr('work_id'));
			}
			if($(e).is(':checked')&&elem.attr('status')!=0){				
				isdel=true;
			}
		})
		if(removearr.length>0){
			 $.confirm("您确定删除作品吗?", "提示", function() {		
			 	var k=0;
				 	var delerfn=function(){				 		
					 		baseAjax('other/work/update_work', 'POST', {work_id: removearr[k],is_delete: 1}, function(data) {
								var time=$('.albumitem[work_id="'+removearr[k]+'"]').attr("add_time");
								var box=$('.albumitem[work_id="'+removearr[k]+'"]').closest(".albumcontain");																
								if(box.children(".albumitem").length==1){									
									box.prev('.workaddtime[time="'+time+'"]').remove();
									box.remove();
									if($(".Not_completedwork").children().length==0){
										$(".Not_completedwork").remove();
									}
								}else{
									$('.albumitem[work_id="'+removearr[k]+'"]').remove();
								}
								//选中的作品的数量
 								selectWork();
								delete UtilProperty[removearr[k]];
								if(k<(removearr.length-1)){
									k++;
									delerfn();
								}
								if($(".albumitem").length==0){
									$(".no_morework").remove();								
									$('.workeritem').after('<div class="weui-cells__title no_work" style="padding-top:50%; text-align:center;">暂无作品</div>');
								}
							})
				 	}
		        	delerfn();			
	        }, function() {
	          //取消操作
	        });		
        }else if(removearr.length==0&& isdel){
        	 $.alert("已提交作品不允许删除", "提示");
        }else{
        	$.alert("请选择要删除的作品", "提示");
        }
		//选中的作品的数量
 		selectWork();
		}
		
	})
	
	//印制作品
	$('.worker_footer').on("click",".copy_btn",function(){
		if(!$(this).hasClass("disablebtn")){
			if($(".workeritem .work_input:checked").length==0){
			 $.alert("请选择作品", "提示");
			}else{
				var isflag;
				var ordernum=0;
				$(".workeritem").find('input.work_input').each(function(i,e){
					var elem=$(e).closest('.work_itemlist');
					if($(e).is(':checked')){
						isflag=checkwork(elem.attr('work_id'));//检测作品中所有的图片控件是否都有填充了图片 或文字
						if(isflag.complete==true){							
							$.alert("填充完整再提交！", "提示");
							return false;
						}
						
						if(isflag.ischange==true){							
							$.alert("请先保存再提交！", "提示");
							return false;
						}
						//ordernum+=1;
						ordernum+=Number(elem.find(".orderNumber").text());
						if(i==0){
							$(".a_type").eq(0).text(UtilProperty[elem.attr('work_id')].workerInfo.work_name);
						}
					}
					
				})				
				if(isflag.complete==false&&isflag.ischange==false){		
					//选中的作品的数量
 					selectWork()
					
					
					document.title='提交作品';
					
					$(".a_type").eq(1).text(ordernum);
					$(".worker_con").hide();
					$(".submitalbum").show();
					//复制订单编号
					var order_sn = $.cookie('order_no');
					if(/^(E\d{23}|C\d{20})$/.test(order_sn)){
						$(".submitalbumbox .orderinput").val(order_sn);
					}
				}
				
				
			
			}
		}
		
	})
	
	
	//增加印制数量
	$('.workeritem').on('click',".order_add ",function(){
		var valnum=parseInt($(this).prev(".orderNumber").text())+1;
		$(this).prev(".orderNumber").text(valnum);	
		//选中的作品的数量
 		selectWork()
	})
	//减少印制数量
	$('.workeritem').on('click',".order_jian ",function(){
		var valnum=parseInt($(this).next(".orderNumber").text());
		if(valnum>1){
			valnum--;
			$(this).next(".orderNumber").text(valnum);
		}
		//选中的作品的数量
 		selectWork()
		
	})
	
	$("#show_worker").scroll(function () {  // 作品页分页加载	
		var viewH =$(this).height(),//可见高度
          contentH =$(this).get(0).scrollHeight,//内容高度
         scrollTop =$(this).scrollTop();//滚动高度
	   if(scrollTop/(contentH -viewH)>=0.95){  
	   	if(pageEnd){
	   		pageEnd=false;
	   		$('.workeritem').after('<div class="weui-loadmore"><i class="weui-loading"></i><span class="weui-loadmore__tips">正在加载</span></div>');
				compeltework_list(pageNoSize);
				console.log(pageEnd)
				
			}
			
			
	     }
	
	 });
	 
	 //选中多少张作品
	$('#show_worker').on("click","input.work_input",function(){
		
		//选中的作品的数量
 		selectWork();
 		
		
	})
	
	
})




//作品页面初始化接口 并且生成作品
function initializationwork(w_id,fn){
	baseAjax('other/work/init_work','GET',{work_id:w_id,is_return:1},function(data){		
			UtilProperty[w_id].worker=data.data;			
			fn();
			
			
		})
	
}

//生成年
function getYear(min,max,fn){	
	var val=[];
	for(var i=min; i<max; i++){
		var str=i.toString()+'年';
		val.push(str);
		
	}	
	fn(val)
	
}
//选中的作品的数量
function selectWork(){
	//var len=$(".workeritem .work_input:checked").length;
	var len=0;
	$(".workeritem .work_itemlist").each(function(i,e) {
		if($(e).find('.work_input').is(":checked")){
			//len=len+Number($(e).find('.orderNumber').text());
			len=len+1;
		}
		
	});
	
	
	$(".notice_num").animate({bottom:(len>0?'50px':'0px')}, "slow").text('已选'+len+'张');
	$(".notice_num").css('display',(len>0?'block':'none'));
	if(len>0){
		$(".worker_footer a").removeClass('disablebtn');
	}else{
		$(".worker_footer a").addClass('disablebtn');
	}
		
	
}


//未完成我的作品
var idarr=new Array;//所有的作品id 和 产品id
function getwork_list(){	
	baseAjax('other/work/work_list','GET',{user_id:user_id,sku_code:sku_code,status:0,page:1},function(data){
		var arr=data.data;
		if($('.show_worker').children().hasClass("no_work")){
				$(".no_work").remove();
			}
		if(arr.length>0){			
			$('.workeritem').prepend('<div class="Not_completedwork"></div>');
		var workerhtml=new Object;
		for(var i=0; i<arr.length;i++){			
			var item=arr[i];
			UtilProperty[item.id]=new Object;
			UtilProperty[item.id].workerInfo=item;	
			var time=formatDate(item.add_time);				
			var image_numstr=getimage_num(item.image_num).image_numstr;				
			var scale=album_wid/item.width;
			if($('.workaddtime[time="'+time+'"]').length==0){
				//$(".Not_completedwork").prepend('<div class="weui-cells__title workaddtime" time="'+time+'">'+time+'</div><div class="albumcontain boxflexThu" time="'+time+'"></div>');
				$(".Not_completedwork").append('<div class="weui-cells__title workaddtime" time="'+time+'">'+time+'</div><div class="albumcontain boxflexThu" time="'+time+'"></div>');
			
			}
			/*var htm='<div class="albumitem work_itemlist itemflex" product_id="'+item.product_id+'" work_id="'+item.id+'" show_type="'+item.show_type+'"  print_type="'+item.print_type+'" status="'+item.status+'" image_num="'+image_numstr+'" add_time="'+time+'">'+
						'<div class="albumimg" style="height:'+parseInt(scale*item.height)+'px;"></div>'+					     			
						'<div class="weui-cell fr_work">'+
						    '<div class="weui-cell__hd">'+
						     	'<label class="weui-cell weui-check__label" for="'+item.id+'">'+
						     		'<input type="checkbox" class="work_input weui-check" name="checkboxwork" id="'+item.id+'">'+
						     		'<i class="weui-icon-checked"></i>'+
						     	'</label>'+
						    '</div>'+
						'<div class="weui-cell__bd worker_countbox">'+
						    '<div class="worker_count">'+
						     	'<a href="javascript:;" class="order_jian"><img src="img/remove.png"></a>'+
						     	'<span class="orderNumber">1</span>'+
						     	'<a href="javascript:;" class="order_add"><img src="img/add.png"></a>'+
						     	'</div>'+
						    '</div>'+
						'</div>'+
					'</div>';
						*/
				var bgw=Math.floor(item.width*scale/16)*16;		
				var htm='<div class="albumitem work_itemlist itemflex" product_id="'+item.product_id+'" work_id="'+item.id+'" show_type="'+item.show_type+'"  print_type="'+item.print_type+'" status="'+item.status+'" image_num="'+image_numstr+'" add_time="'+time+'">'+
						'<div class="albumimg_top_bg" style="width:'+bgw+'px;"></div>'+
						'<div class="albumimg" style="height:'+parseInt(scale*item.height)+'px;"></div>'+
						'<div class="weui-cell fr_label">'+						    
						    '<label class="weui-cell weui-check__label" for="'+item.id+'">'+
						     	'<input type="checkbox" class="work_input weui-check" name="checkboxwork" id="'+item.id+'">'+
						     	'<i class="weui-icon-checked"></i>'+
						    '</label>'+						
						'</div>'+
					'</div>';
								
						
			if(workerhtml[time]){				
				workerhtml[time]=workerhtml[time]+htm;
			}else{
				workerhtml[time]=htm;	
			}
			var ido={product_id:item.product_id,work_id:item.id}
			idarr.push(ido);
		}
		
		for(var i in workerhtml){
			$('.Not_completedwork .albumcontain[time="'+i+'"]').prepend(workerhtml[i]);
		}		
		
		}else{
			/*if($(".workeritem").children().length==0){
				$("#loadtoast").hide();						
				$('.workeritem').after('<div class="weui-cells__title no_work" style="padding-top:50%; text-align:center;">暂无作品</div>');
			}*/	
		}
		//已提交的作品
		compeltework_list(pageNoSize);
	})
	
}
//已提交的作品
function compeltework_list(page){	
	baseAjax('other/work/work_list','GET',{user_id:user_id,sku_code:sku_code,status:1,page:page},function(data){
		var arr=data.data;
		$(".weui-loadmore").remove();
		if($('.show_worker').children().hasClass("no_work")){
				$(".no_work").remove();
			}
		var arr=data.data;
		var workerhtml=new Object;
		if(arr.length<=0){
			/*if(!$("#loadtoast").is(":hidden")){
				$("#loadtoast").hide();
			}*/
			if($(".completedwork").children().length==0){
				//$("#loadtoast").hide();				
			}else{
				$('.workeritem').after('<div class="weui-cells__title no_morework">没有更多了</div>');
			}
			
			if($(".workeritem").children().length==0){
				//$("#loadtoast").hide();						
				$('.workeritem').after('<div class="weui-cells__title no_work" style="padding-top:50%; text-align:center;">暂无作品</div>');
			}	
		
			getreadyworker();
			pageEnd=false;
		}else{
			if(pageNoSize==1){
			$('.workeritem').append('<div class="completedwork"><h6 class="completehr"><span></span></h6></div>');			
			
			}
			
			pageNoSize=pageNoSize+1;		
	
		for(var i=0; i<arr.length;i++){			
			var item=arr[i];
			UtilProperty[item.id]=new Object;
			UtilProperty[item.id].workerInfo=item;	
			var time=formatDate(item.add_time);				
			var image_numstr=getimage_num(item.image_num).image_numstr;				
			var scale=album_wid/item.width;
			if($('.completedwork .workaddtime[time="'+time+'"]').length==0){
				$(".completedwork").append('<div class="weui-cells__title workaddtime" time="'+time+'">'+time+'</div><div class="albumcontain boxflexThu" time="'+time+'"></div>');
			}			
			/*var htm='<div class="albumitem itemflex" product_id="'+item.product_id+'" work_id="'+item.id+'" show_type="'+item.show_type+'"  print_type="'+item.print_type+'" status="'+item.status+'" image_num="'+image_numstr+'" add_time="'+time+'">'+
						'<div class="albumimg" style="height:'+parseInt(scale*item.height)+'px;"></div>'+					     			
						'<div class="weui-cell fr_work">'+
						    '<div class="weui-cell__hd">'+
						     	'<label class="weui-cell weui-check__label" for="'+item.id+'">'+
						     		'<input type="checkbox" class="work_input weui-check" name="checkboxwork" id="'+item.id+'">'+
						     		'<i class="weui-icon-checked"></i>'+
						     	'</label>'+
						    '</div>'+
						'<div class="weui-cell__bd worker_countbox">'+
						    '<div class="worker_count">'+
						     	'<a href="javascript:;" class="order_jian"><img src="img/remove.png"></a>'+
						     	'<span class="orderNumber">1</span>'+
						     	'<a href="javascript:;" class="order_add"><img src="img/add.png"></a>'+
						     	'</div>'+
						    '</div>'+
						'</div>'+
					'</div>';*/
				var bgw=Math.floor(item.width*scale/16)*16;			
				var htm='<div class="albumitem work_itemlist itemflex" product_id="'+item.product_id+'" work_id="'+item.id+'" show_type="'+item.show_type+'"  print_type="'+item.print_type+'" status="'+item.status+'" image_num="'+image_numstr+'" add_time="'+time+'">'+
						'<div class="albumimg_top_bg" style="width:'+bgw+'px;"></div>'+
						'<div class="albumimg" style="height:'+parseInt(scale*item.height)+'px;"></div>'+
						'<div class="weui-cell fr_label">'+						    
						    '<label class="weui-cell weui-check__label" for="'+item.id+'">'+
						     	'<input type="checkbox" class="work_input weui-check" name="checkboxwork" id="'+item.id+'">'+
						     	'<i class="weui-icon-checked"></i>'+
						    '</label>'+						
						'</div>'+
						'<div class="copyyes"><img src="img/yin.png"></div>'+
					'</div>';	
						
			if(workerhtml[time]){				
				workerhtml[time]=workerhtml[time]+htm;
			}else{
				workerhtml[time]=htm;	
			}
			var ido={product_id:item.product_id,work_id:item.id}
			idarr.push(ido);
		}
		
		for(var i in workerhtml){
			$('.completedwork .albumcontain[time="'+i+'"]').prepend(workerhtml[i]);
		}
		//得到作品图片
		getreadyworker();
		pageEnd=true;
		
		}
		
	})
	
}


//得到图片的张数
function getimage_num(image_num){	
	var small_image_num, large_image_num,title_str;
	if(image_num.indexOf(">=") >= 0) {
		small_image_num = image_num.split('=')[1];
		title_str="至少上传"+small_image_num+"张照片";
	} else if(image_num.indexOf("<=") >= 0) {
		large_image_num = image_num.split('=')[1];
		title_str="最多上传"+large_image_num+"张照片";
	} else if(image_num.indexOf("-") >= 0) {
		small_image_num = image_num.split('-')[0];
		large_image_num = image_num.split('-')[1];
		title_str="上传"+image_num+"张照片";
	} else if(image_num.indexOf(",") >= 0) {
		small_image_num = image_num.split(',')[0];
		large_image_num = image_num.split(',')[1];
		title_str="上传"+small_image_num+"或"+large_image_num+"张照片";
	}else{
		small_image_num = image_num;
		large_image_num = image_num;
		title_str="上传"+image_num+"张照片";
	}

	if(small_image_num && large_image_num) {
		image_numstr = small_image_num + '-' + large_image_num;
	} else {
		if(small_image_num) {
			image_numstr = small_image_num;
		} else {
			image_numstr = large_image_num;
		}
	}
	var image_number=new Object;
	image_number.small_image_num=small_image_num;
	image_number.large_image_num=large_image_num;
	image_number.image_numstr=image_numstr;
	image_number.title_str=title_str;
	
	return image_number;
}


//时间戳怎么转成日期格式
/* function getLocalTime(nS) {     
       return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, ".").replace(/日/g, " ");      
    } */
   
//把时间戳转成日期
function formatDate(now) { 
	if(now!=""){
		var time=new Date(now*1000);
	}else{
		var time=new Date();
	}	 
	 var year = time.getFullYear();
	 var month = time.getMonth() + 1;
	var day = time.getDate();
	 /* var hour = time.getHours();
	 var minute = time.getMinutes();
	 var second = time.getSeconds();*/
	 return year + "-" + (month<10?'0'+month:month)+ "-" + (day<10?'0'+day:day);
 }
            

//把套餐配送的食品的FdNo排序
function sortNumber(a,b)
	{
	return a.add_time > b.add_time ? -1 : 1; // 这里改为大于号  
	//return a.add_time - b.add_time;
	}
	

function getreadyworker(){
	if(idarr.length==0){
		$("#loadtoast").hide();
	}
	for(var i=0;i< idarr.length; i++){
		var w_id=idarr[i].work_id;
		//获取已经存在的作品的作品页面信息
		baseAjax('other/work/work_page_list','GET',{work_id:w_id},function(data){
			
				if(UtilProperty[w_id]==null){
					UtilProperty[w_id]=new Object;
				}
				UtilProperty[w_id].worker=data.data;			
				UtilProperty[w_id].imageObj=new Object;
				if(UtilProperty[w_id].worker.length>0){
					var mulitImg=[];									
					var isfla=false;
					for(var j=0; j<data.data.length;j++){
						if(data.data[j].page==1){
							var item=UtilProperty[w_id].worker[j];	
							UtilProperty[w_id].worker[j].background.ischange=false;																							
							if(item.background_id!=0){// lym 2018.01.04 修改 图片加载 原先的的id标志转为url标志	
								var bgurl=item.background.image_url+bgsize_str;	
								UtilProperty[w_id].worker[j].background.image_url=bgurl;	
								if(UtilProperty.background.backgroundimage[bgurl]==undefined){
									mulitImg.push(bgurl);
									UtilProperty.background.backgroundimage[bgurl]=null;
									isfla=true;
								}
							}							
							for(k=0; k<item.control_list.length;k++){
								var element=item.control_list[k];
								UtilProperty[w_id].worker[j].control_list[k].ischange=false;
								if(element.control_id==1){	
									if(element.element_list instanceof Array&&element.element_list.length>0){
									var list=element.element_list[0];
										if(list.image_url!=""){// lym 2018.01.04 修改 图片加载 原先的的id标志转为url标志	
											var img_url=list.image_url+imgsize_str;
											UtilProperty[w_id].worker[j].control_list[k].element_list[0].image_url=img_url; // lym 2018.01.02 修改 图片加载 原先的的id标志转为url标志
											if($.inArray(img_url, mulitImg)==-1){
												mulitImg.push(img_url);										
												isfla=true;
											}
										}
									}
		
								
								}else if(element.control_id==3){//lym 2017 11.17 新增月历修改
									if(element.element_list.length>0){
									var dateList=element.element_list[0];								
									if(dateList.style!=""&&dateList.style!=undefined){
										var a=JSON.parse(dateList.style);
										var fontstyle={align:a.align,color:a.color,direction:a.direction,line_space:a.line_space,max:a.max,size:a.size,format:a.format};
										var year=dateList.content.split('-')[0];
										var month=dateList.content.split('-')[1]
										if(year!=''&&month!=undefined){
											UtilProperty[w_id].worker[j].control_list[k].element_list[0].date_list=calendarMonthdata(year,month,a.column,a.weekstyle,element.width,element.height,fontstyle);
										}
										
									}
									}
								}
							}
							break;
						}
					}
					if(isfla){						
						//判断图片是否完全加载完毕
						imagelistToObject(mulitImg,w_id,function(){
							
							startcover();						
						})
					}else{
						startcover();
					}
					
				}else{					
					baseAjax('other/work/init_work','GET',{work_id:w_id,is_return:1},function(data){		
						UtilProperty[w_id].worker=data.data;						
						var item=UtilProperty[w_id].worker[0];
					var mulitImg=[];
					var mulitImgid=[];					
					var isfla=false;
					for(var j=0; j<data.data.length;j++){
						if(data.data[j].page==1){
							var item=UtilProperty[w_id].worker[j];	
							UtilProperty[w_id].worker[j].background.ischange=false;
							for(k=0; k<item.control_list.length;k++){
								var element=item.control_list[k];	
								UtilProperty[w_id].worker[j].control_list[k].ischange=true;
								if(item.background_id!=0){// lym 2018.01.04 修改 图片加载 原先的的id标志转为url标志	
									var bgurl=item.background.image_url+bgsize_str;	
									UtilProperty[w_id].worker[j].background.image_url=bgurl;	
									if(UtilProperty.background.backgroundimage[bgurl]==undefined){
										mulitImg.push(bgurl);
										UtilProperty.background.backgroundimage[bgurl]=null;
										isfla=true;
									}
								}	
								
								if(element.control_id==1){	
									if(element.element_list instanceof Array&&element.element_list.length>0){
										var list=element.element_list[0];
										if(list.image_url!=""){// lym 2018.01.04 修改 图片加载 原先的的id标志转为url标志	
											var img_url=list.image_url+imgsize_str;
											UtilProperty[w_id].worker[j].control_list[k].element_list[0].image_url=img_url; // lym 2018.01.02 修改 图片加载 原先的的id标志转为url标志
											if($.inArray(img_url, mulitImg)==-1){
												mulitImg.push(img_url);										
												isfla=true;
											}
										}
									}
		
								
								}else if(element.control_id==3){//lym 2017 11.17 新增月历修改   2017.12.6 解决1月重复问题
									if(element.element_list.length>0){
									var dateList=element.element_list[0];								
									if(dateList.style!=""&&dateList.style!=undefined){
										var a=JSON.parse(dateList.style);
										var fontstyle={align:a.align,color:a.color,direction:a.direction,line_space:a.line_space,max:a.max,size:a.size,format:a.format};
										var year=dateList.content.split('-')[0];
										var month=dateList.content.split('-')[1]
										if(year!=''&&month!=undefined){
											UtilProperty[w_id].worker[j].control_list[k].element_list[0].date_list=calendarMonthdata(year,month,a.column,a.weekstyle,element.width,element.height,fontstyle);
										}
										
									}
									}
								}
							}
							break;
						}
					}
					if(isfla){						
						//判断图片是否完全加载完毕
						imagelistToObject(mulitImg,w_id,function(){
							startcover();							
						})
					}else{
						startcover();
					}
										
					})
					
				}	
				
				
			})	
		break;	
	}
	
	
}


//检测作品中所有的控件是否都有填充了图片或文字
function checkwork(w_id){
	var result=new Object;
	result.complete=false;
	result.ischange=false;	
	var worker=UtilProperty[w_id].worker;	
	if(worker.length>0){	
		for(i=0; i<worker.length;i++){		
			var item=worker[i];
			if(item.background.ischange==true){
				result.ischange=true;
				//return result;
			}
			if(item.control_list.length>0){
				for(k=0; k<item.control_list.length;k++){
					var element=item.control_list[k];			
					if(element.control_id==1){				
						if(element.element_list instanceof Array&&element.element_list.length>0){						
							if(!element.element_list[0].image_url){					
								result.complete=true;
							    // return result;
							}
						//console.log(i)		
						}else{
							result.complete=true;
							//return result;
						}
						
						
					}else if(element.control_id==2||element.control_id==3){//lym 2017 11.22 新增月历修改				
						if(element.element_list instanceof Array&&element.element_list.length>0){						
							if(element.element_list[0].content==''||!element.element_list[0].content){					
								result.complete=true;
							     //return result;
							}
						//console.log(i)		
						}else{
							result.complete=true;
							//return result;
						}
						
					}
					
					if(element.ischange){
						result.ischange=true;
						//return result;
					}
				}
			}else{
				if(!(item.title=="封面"||item.title=="封底"||item.title=="扉页")){
					result.complete=true;
					//return result;
				}
				
				
			}
			
			if(result.complete==true&&result.ischange==true){
				return result;
			}
			
		}
	}else{
			result.complete=true;
			//return result;
	}
	return result;
}